﻿<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" import="com.iwords.service.object.*"  %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> 
<head>
 	<title>5iwords</title>
	
	<link rel="stylesheet" href="css/pagination.css" />

	<script src="js/jquery-1.6.2.min.js" type="text/javascript"></script>
	<script type="text/javascript">
		function getChildren(){
			
		}
	</script>
</head>
<body>
	<div id="content" class="choose">
		<div class="layout grid-s4m0">
			<div class="col-main">
				<div class="main-wrap">
					<div id="tab1" class="med-list-tab">
						<ul>
							<li class="current" id="tab_0"><a href="#" class="icon irecord">我的词汇</a></li>
							<c:forEach items="${sysLibList}" var="u" varStatus="s">
							<li class="" id="tab_${s.index+1}" libid="${u.libid}" loaded="false"><a href="#" class="ibook" >${u.libname}</a></li>
							</c:forEach>
						</ul>
					</div>
					
					<div class="med-table med-table2 " id="table_0">
						<div class="icon G-desc">
                                                    
                                                    <c:if test="${empty currentLib}">
					 你当前还没有学习课本,加油哦
					</c:if>
                                                       <c:if test="${!empty currentLib}">
					 
					
							您当前学习的课本为<<${currentLib.libname}>>，总计<strong>${currentLib.quantity}</strong>单词，已经记住了<strong>${currentLib.downNum}
								</strong>个单词，还有<strong>
								<c:out value="${currentLib.quantity-currentLib.downNum}"></c:out>
								 </strong>个在记忆中，继续努力，加油哦
		</c:if>
						</div>
					<!-- {{{ table -->
					<table class="account_table  lesson_table">
						<tr class="title">
							<th>课程名称</th>
							<th>单词总量</th>
							<th>类别</th>
							<th>完成进度</th>
							<th>操作</th>
						</tr>
						<c:forEach items="${studyList}" var="u" varStatus="s">
							<tr align="left" class="hlight">
								<td class="node node-collapsed"
									onclick="getChildren()"><i
									class=""></i> <c:out value="${u.libname}" />
								</td>
								<td width="124"><c:out value="${u.quantity}" />
								</td>
								<td width="105"><c:if test="${u.isFree==true}" var="result">
	        			 免费
	   				 </c:if> <c:if test="${u.isFree!=true}" var="result">
	         			付费
	    				</c:if>
								</td>
								<td width="124" class="activity"><span class="activity-bar"><span
										style="width: 100%;">${u.percent*10}</span> </span>${u.percent}%</td>
								<td width="172"><a href="learningStatus?action=study&libid=${u.libid}" class="buy"> 我要学习 </a>
								</td>
							</tr>
						</c:forEach>
	
					</table>
					<!-- table }}} -->
					<!-- {{{ pagination -->
					<div class="pagination">
						<div class="page-top">
							<a href="?action=list&toPage=1" class="page-begin"><span>首页</span>
							</a> 
				            <a href="?action=list&toPage=${toPage-1}" class="page-pre"><span>上一页&gt;</span> </a>
							<c:forEach var="num" begin="1" end="${totalPage}">
								<a href="?action=list&toPage=${num}"><span>${num}</span> </a>
							</c:forEach>
							<a href="?action=list&toPage=${toPage+1}" class="page-next"><span>下一页&gt;</span> </a>
							
						</div>
					</div>
				</div>
				<c:forEach items="${sysLibList}" var="u" varStatus="s">	
					<div class="med-table ks-hidden" id="table_${s.index+1}">
						<div class="icon G-desc">
								                      <c:if test="${empty currentLib}">
					 你当前还没有学习课本,加油哦
					</c:if>
                                                       <c:if test="${!empty currentLib}">
					 
					
							您当前学习的课本为<<${currentLib.libname}>>，总计<strong>${currentLib.quantity}</strong>单词，已经记住了<strong>${currentLib.downNum}
								</strong>个单词，还有<strong>
								<c:out value="${currentLib.quantity-currentLib.downNum}"></c:out>
								 </strong>个在记忆中，继续努力，加油哦
		</c:if>
                                                </div>
						<div id="lessonTable_${u.libid}">
							
						</div>
					</div>
				</c:forEach>
				<!-- table }}} -->
				<!-- {{{ pagination -->

				<!-- pagination }}} -->
				
				
				</div>
				
			</div>
			<div class="col-sub">
				<div class="s-box s-box-weak groupbox">
					<u class="s-box-top"><s></s><b></b></u>
					<div class="s-box-hd">
						<h3 class="s-box-title">我要背单词</h3>
					</div>
					<div class="s-box-bd">
						<div class="bd">
							<ul>
								<li><i class="icon mylesson"></i><a href="#">我的教材</a></li>
								<li><i class="icon review"></i><a href="learningStatus?action=study">单词复习</a></li>
								<li><i class="icon setting"></i><a href="user?action=getconfig">功能设置</a></li>
							</ul>
						</div>
					</div>
				</div>
			</div>
		</div>
		
	</div>
	
	<div id="footer">
		<div class="layout grid-m">
			<div class="col-main">
				<div class="rights">© Copyright 2010~2011, All Rights Reverved.Supported By BanRuoLang.</div>
			</div>
		</div>
	</div>
<script type="text/javascript">


$(document).ready(function(){
	$("#tab1 li").each(function(i,node){
		$(node).click(function(e){
			e.preventDefault();
			
			if($(this).hasClass('current')){
				return ;
			}
			else{
				if($(this).attr("libid")){
					if($(this).attr("loaded")=="false"){
						loadSysLib($(this).attr("libid"));
						$(this).attr("loaded","true");
						init();
					}
				}
			
				$('#tab1 li').removeClass('current');
				$(this).addClass('current');
				$('.med-table').addClass('ks-hidden');
				$('.med-table').eq(i).removeClass('ks-hidden');
			}
		})
	})
	
});

   function loadSysLib(libid){
	   $.ajax({
			type: "POST",
			url:"ajaxApi?action=children&libid="+libid,
			cache: true,
			success: function(ajaxResult){
				$("#lessonTable_"+libid).html(ajaxResult);
				init();
			},
			
			clearForm: true
		});   
   };
   
   function init(){
		$(".parentNode").each(function(i,node){
			$(node).unbind('click').click(function(e){
				e.preventDefault();
				var libid=$(this).attr("libid");
				if($(this).hasClass('node-collapsed')){
					
					loadSysLib(libid);
					
					$(this).removeClass('node-collapsed');
					$("#nodedetail_"+libid).removeClass('ks-hidden');
				}else{
					$(this).addClass('node-collapsed');
					$("#nodedetail_"+libid).addClass('ks-hidden');
				}
			})
			
		})
	}
   
   

</script>
</body>
</html>